<template>
  <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="输入字段设置(LIS报告录入)" :visible.sync="ConfigVisible" v-if="ConfigVisible" width="755px" style="padding:5px 5px 5px 5px" top="6vh">
      <div style="float:left;width:630px" class="Config">
          <vxe-table :data.sync="tableDataColumn" @current-change="currentChangeEvent" :sort-config="{trigger: 'cell'}" :edit-config="{trigger: 'click', mode: 'cell',showStatus: true}" :mouse-config="{selected: true}" :select-config="selectConfig" :keyboard-config="keyConfig" height="450px" highlight-current-row highlight-hover-row ref="xTableColumn" resizable highlight-hover-column show-header-overflow="tooltip" show-overflow="tooltip" header-align="center" size="mini" border stripe width="630px">
              <vxe-table-column type="index" align="center" width="30px"></vxe-table-column>
              <vxe-table-column field="col_name" key="col_name" title="字段名称" width="80px"></vxe-table-column>
              <vxe-table-column field="col_label" key="col_label" title="提示文字" :edit-render="{name: 'input', autoselect: true}" width="80px"></vxe-table-column>
              <vxe-table-column field="default_valname" key="default_val" title="默认值" :edit-render="{name: 'input', autoselect: true}" width="80px">
                  <template v-slot:edit="{row}">
                      <el-input v-model="row.default_val" v-if="row.col_code === 'lab_advice'" size="mini"></el-input>
                      <el-input v-model="row.default_val" v-else-if="row.col_code === 'pat_agestr'" size="mini"></el-input>
                      <el-input v-model="row.default_val" v-else-if="row.valuetype == '2'" size="mini" :ref="row.col_code"></el-input>
                      <el-date-picker v-model="row.default_val" v-else-if="row.valuetype === '7'" :inputable="true" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" size="mini" style="width:100%"></el-date-picker>
                      <el-input v-model="row.default_valname" @dblclick.native="inputdblEvent(row.col_code)" @change="inputChangeEvent($event, row.col_code)" @focus="Queryddl('LIS3_' + row.col_code)" v-else-if="row.valuetype == '5'" size="mini"></el-input>
                  </template>
              </vxe-table-column>
              <vxe-table-column field="visibled" key="visibled" title="可见" width="30px" align="center">
                  <template v-slot="{row}">
                      <el-checkbox label="" v-model="row.visibled"></el-checkbox>
                  </template>
              </vxe-table-column>
              <vxe-table-column field="enabled" key="enabled" title="可编辑" width="40px" align="center">
                  <template v-slot="{row}">
                      <el-checkbox label="" v-model="row.enabled"></el-checkbox>
                  </template>
              </vxe-table-column>
              <vxe-table-column field="noedit" key="noedit" title="禁止双击" width="55px" align="center">
                  <template v-slot="{row}">
                      <el-checkbox label="" v-model="row.noedit"></el-checkbox>
                  </template>
              </vxe-table-column>
              <vxe-table-column field="rem_last" key="rem_last" title="自动记忆" width="55px" align="center">
                  <template v-slot="{row}">
                      <el-checkbox label="" v-model="row.rem_last"></el-checkbox>
                  </template>
              </vxe-table-column>
              <vxe-table-column field="bold" key="bold" title="加粗" width="40px" align="center">
                  <template v-slot="{row}">
                      <el-checkbox label="" v-model="row.bold"></el-checkbox>
                  </template>
              </vxe-table-column>
              <vxe-table-column field="col_code" key="col_code" title="字段代码" width="80px"></vxe-table-column>
              <vxe-table-column field="rowheight" key="rowheight" title="行高" width="80px" :edit-render="{name: 'input', autoselect: true}"></vxe-table-column>
          </vxe-table>
      </div>
      <div style="float:left;margin-left: 5px">
          <table>
              <tr>
                  <td style="text-align:left">
                      <el-button style="width:80px;margin-bottom: 5px" @click="SaveCol()">确定</el-button>
                  </td>
              </tr>
              <tr>
                  <td style="text-align:left">
                      <el-button style="width:80px;margin-bottom: 50px" @click="ConfigVisible=false">取消</el-button>
                  </td>
              </tr>
              <tr>
                  <td style="text-align:left">
                      <el-button style="width:80px;margin-bottom: 5px" @click="SetFirst($refs.xTableColumn)">首位</el-button>
                  </td>
              </tr>
              <tr>
                  <td style="text-align:left">
                      <el-button style="width:80px;margin-bottom: 5px" @click="SetUp($refs.xTableColumn)">上移</el-button>
                  </td>
              </tr>
              <tr>
                  <td style="text-align:left">
                      <el-button style="width:80px;margin-bottom: 5px" @click="SetDown($refs.xTableColumn)">下移</el-button>
                  </td>
              </tr>
              <tr>
                  <td style="text-align:left">
                      <el-button style="width:80px;margin-bottom: 5px" @click="SetLast($refs.xTableColumn)">末位</el-button>
                  </td>
              </tr>
              <tr>
                  <td style="text-align:left">
                      <el-button style="width:80px;margin-bottom: 5px" @click="resort($refs.xTableColumn)">默认顺序</el-button>
                  </td>
              </tr>
              <tr>
                  <td style="text-align:left">
                      <el-button style="width:80px;margin-bottom: 5px" @click="BatChangeColumn">批量修改字段</el-button>
                  </td>
              </tr>
              <tr>
                  <td style="text-align:left">
                      <el-button style="width:80px;height:36px;margin-bottom: 5px" @click="CopyToOtherUnit">复制到其他<br />报告单元</el-button>
                  </td>
              </tr>
              <!-- <tr>
                      <td style="text-align:left">
                          <el-button style="width:110px;margin-bottom: 5px">列表字段调整</el-button>
                      </td>
                  </tr> -->
              <!-- <tr>
                      <td style="text-align:left;">
                          <div style="margin-top: 20px">文字大小</div>
                      </td>
                  </tr>
                  <tr>
                      <td>
                          <el-select v-model="ConfigDetail[ConfigDetail.tab_length-1]">
                              <el-option label="小" value="1"></el-option>
                              <el-option label="中" value="2"></el-option>
                              <el-option label="大" value="3"></el-option>
                              <el-option label="超大" value="4"></el-option>
                          </el-select>
                      </td>
                  </tr> -->
              <!--<tr>
                      <td style="text-align:left">
                          <el-checkbox>自动记忆样式</el-checkbox>
                      </td>
                  </tr>
                  <tr>
                      <td style="text-align:left">行间距</td>
                  </tr>
                  <tr>
                      <td>
                          <el-input-number v-model="rowdistance" controls-position="right" :min="1" :max="1000"></el-input-number>
                      </td>
                  </tr>-->
          </table>
      </div>
      <div style="margin-top: 5px">
          <table>
              <tr>
                  <td colspan="4">
                      <table style="border-spacing:2px">
                          <tr>
                              <td style="text-align:left">
                                  <el-checkbox v-model="ConfigDetail.tab_list">列表</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox v-model="ConfigDetail.tab_img">图像</el-checkbox>
                              </td>
                              <td style="text-align:left">
                                  <el-checkbox v-model="ConfigDetail.tab_history">历史结果</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox v-model="ConfigDetail.tab_input">输入</el-checkbox>
                              </td>
                              <td style="text-align:left">
                                  <el-checkbox v-model="ConfigDetail.tab_wait">待查样本</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox v-model="ConfigDetail.tab_req">申请</el-checkbox>
                              </td>
                              <td style="text-align:left">
                                  <el-checkbox v-model="ConfigDetail.tab_redo">复查</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox v-model="ConfigDetail.tab_instrdiag">仪器诊断</el-checkbox>
                              </td>
                              <td style="text-align:left">
                                  <el-checkbox v-model="ConfigDetail.tab_tel">通讯</el-checkbox>
                              </td>

                          </tr>
                      </table>
                  </td>
              </tr>
              <tr>
                  <td style="text-align:left" colspan="4">
                      <table style="border-spacing:2px">
                          <tr>
                              <td style="text-align:left">
                                  <el-checkbox v-model="ConfigDetail.tab_insdata">仪器原始结果</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox v-model="ConfigDetail.tab_exdata">扩展信息</el-checkbox>
                              </td>
                              <td style="text-align:left">
                                  <el-checkbox v-model="ConfigDetail.tab_simg">样本图像</el-checkbox>
                              </td>
                              <td>
                                  <el-checkbox v-model="ConfigDetail.tab_advice">检验意见</el-checkbox>
                              </td>
                              <td style="text-align:left">
                                  <el-checkbox v-model="ConfigDetail.tab_log">日志</el-checkbox>
                              </td>
                              <td style="text-align:left">
                                  <el-checkbox v-model="ConfigDetail.tab_mixde">混样明细</el-checkbox>
                              </td>
                              <td style="text-align:left">
                                  <el-checkbox v-model="ConfigDetail.tab_alert">危急值项目</el-checkbox>
                              </td>
                          </tr>
                      </table>
                  </td>
              </tr>
              <tr>
                  <!-- <td style="text-align:left">
                      <el-checkbox v-model="ConfigDetail.set_hidseq">隐藏结果前序号</el-checkbox>
                  </td> -->
                  <!-- <td>
                      <el-checkbox v-model="ConfigDetail.set_hishscroll">隐藏结果水平滚动条</el-checkbox>
                  </td> -->
                  <!-- <td style="text-align:left">
                      <el-checkbox v-model="ConfigDetail.set_wave">相关结果显示波动图</el-checkbox>
                  </td> -->
                  <!-- <td>
                      <el-checkbox v-model="ConfigDetail.set_ndbclk">不可编辑字段双击也不可编辑</el-checkbox>
                  </td> -->
                  <td style="width: 120px;text-align:left;">
                      <el-checkbox v-model="ConfigDetail.set_imgori">图形保持原始尺寸</el-checkbox>
                  </td>
                  <!-- <td>
                      <el-checkbox v-model="ConfigDetail.set_imghs">图形横向排列</el-checkbox>
                  </td> -->
                  <td style="width:100px;text-align:left;">
                      <el-checkbox v-model="ConfigDetail.set_imgget">启用图形捕获</el-checkbox>
                  </td>
                  <td style="width: 100px;text-align:left;">
                      <el-checkbox v-model="ConfigDetail.set_hisimgna">隐藏图形名称</el-checkbox>
                  </td>
                  <td style="width: 70px;text-align:left;">缩略图宽高度:</td>
                  <td style="width: 100px;">
                      <el-input v-model="ConfigDetail.set_thumbnailwidth" style="width:40px;"></el-input>
                      <span>：</span>
                      <el-input v-model="ConfigDetail.set_thumbnailheight" style="width:40px;"></el-input>
                  </td>
              </tr>

          </table>
      </div>

      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="poptitle" :visible.sync="dialogTableVisible" v-if="dialogTableVisible" ref="popcommondialog">
          <rm-pop-common @cancel="dialogTableVisible=false" :datatype="popdatatype" :rptunitid="rptunitid" @change="popchange" ref="popcommon"></rm-pop-common>
          <!--LIS3_xxx-->
      </el-dialog>

      <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="输入字段批量设置" :visible.sync="dialogBatVisible" v-if="dialogBatVisible">

          <div class="top-row top-row-content">
              <div>
                  <span class="top-row-title">输入字段</span>
                  <span>
                      <rm-ddl-common :appendtobody="true" datatype="inputcol" v-model="inputcolcode" width="155px" @change="QueryBatCol"></rm-ddl-common>
                  </span>
                  <span class="top-row-title">工作组</span>
                  <span>
                      <rm-ddl-common :appendtobody="true" datatype="labgroup" v-model="labgroupid" width="155px" @change="QueryBatCol"></rm-ddl-common>
                  </span>
              </div>
              <div>
                  <el-button @click="btngetAllRptunit()">补全所有报告单元</el-button>
                  <el-button @click="SaveBatCol()">保 存</el-button>
                  <el-button @click="dialogBatVisible = false">取 消</el-button>
              </div>
          </div>
          <div style="font-size: 12px;color: blue;padding-top: 2px;padding-bottom: 2px">双击标题可以将第一行的值赋值到后面所有行</div>
          <!-- <table>
                  <tr>
                      <td>输入字段</td>
                      <td>
                          <rm-ddl-common :appendtobody="true" datatype="inputcol" v-model="inputcolcode" width="155px" @change="QueryBatCol"></rm-ddl-common>
                      </td>
                      <td>工作组</td>
                      <td>
                          <rm-ddl-common :appendtobody="true" datatype="labgroup" v-model="labgroupid" width="155px" @change="QueryBatCol"></rm-ddl-common>
                      </td>
                      <td>

                      </td>
                  </tr>
              </table> -->
          <vxe-table :data.sync="tableDataBatCol" @current-change="currentChangeEvent" @header-cell-dblclick="headerdblCellClickEvent" :sort-config="{trigger: 'cell'}" :edit-config="{trigger: 'click', mode: 'cell',showStatus: true}" :mouse-config="{selected: true}" :select-config="selectConfig" :keyboard-config="keyConfig" height="450px" highlight-current-row highlight-hover-row ref="xTableBatColumn" resizable highlight-hover-column show-header-overflow="tooltip" show-overflow="tooltip" header-align="center" size="mini" border stripe width="600px">
              <vxe-table-column field="rptunitname" title="报告单元" width="120px"></vxe-table-column>
              <vxe-table-column field="col_label" title="提示文字" :edit-render="{name: 'input', autoselect: true}" width="80px"></vxe-table-column>
              <vxe-table-column field="default_valname" title="默认值" :edit-render="{name: 'input', autoselect: true}" width="80px">
                  <template v-slot:edit="{row}">
                      <el-input v-model="row.default_val" v-if="row.col_code === 'lab_advice'" size="mini"></el-input>
                      <el-input v-model="row.default_val" v-else-if="row.col_code === 'pat_agestr'" size="mini"></el-input>
                      <el-input v-model="row.default_val" v-else-if="row.valuetype == '2'" size="mini" :ref="row.col_code"></el-input>
                      <el-date-picker v-model="row.default_val" v-else-if="row.valuetype === '7'" :inputable="true" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" size="mini" style="width:100%"></el-date-picker>
                      <el-input v-model="row.default_valname" @change="inputBatChangeEvent($event, row)" v-else-if="row.valuetype == '5'" size="mini"></el-input>
                  </template>
              </vxe-table-column>
              <vxe-table-column field="visibled" title="可见" width="30px" align="center">
                  <template v-slot="{ row }">
                      <el-checkbox label="" false-label="0" true-label="1" v-model="row.visibled"></el-checkbox>
                  </template>
              </vxe-table-column>
              <vxe-table-column field="enabled" title="可编辑" width="40px" align="center">
                  <template v-slot="{ row }">
                      <el-checkbox label="" false-label="0" true-label="1" v-model="row.enabled"></el-checkbox>
                  </template>
              </vxe-table-column>
              <vxe-table-column field="noedit" title="禁止双击" width="55px" align="center">
                  <template v-slot="{row}">
                      <el-checkbox label="" false-label="0" true-label="1" v-model="row.noedit"></el-checkbox>
                  </template>
              </vxe-table-column>
              <vxe-table-column field="rem_last" title="自动记忆" width="55px" align="center">
                  <template v-slot="{row}">
                      <el-checkbox label="" false-label="0" true-label="1" v-model="row.rem_last"></el-checkbox>
                  </template>
              </vxe-table-column>
              <vxe-table-column field="col_code" title="字段代码" width="80px"></vxe-table-column>
              <vxe-table-column field="rowheight" key="rowheight" title="行高" width="80px" :edit-render="{name: 'input', autoselect: true}"></vxe-table-column>
              <vxe-table-column field="bold" title="加粗" width="40px" align="center">
                  <template v-slot="{ row }">
                      <el-checkbox label="" false-label="0" true-label="1" v-model="row.bold"></el-checkbox>
                  </template>
              </vxe-table-column>
          </vxe-table>
      </el-dialog>
      <el-dialog v-el-drag-dialog  :append-to-body="true" :close-on-click-modal="false" title="复制输入字段" :visible.sync="CopyShow" v-if="CopyShow" width="500px">
          <table>
              <tr>
                  <td style="text-align:right">
                      当前报告单元:
                  </td>
                  <td>
                      <rm-ddl-rptunit prgno="LIS310" v-model="rptunitid" :appendtobody="true" width="200px" :defaultflag="'1'" :disabled="true"></rm-ddl-rptunit>
                  </td>
              </tr>
              <tr>
                  <td style="text-align:right">
                      请选择要复制到的报告单元:
                  </td>
                  <td>
                      <el-select v-model="rptunitidcopy" @dblclick.native="popMultipleChk(rptunitidcopy)" filterable clearable style="width:100%" placeholder="可双击开窗多选报告单元">
                          <el-option v-for="(item,index) in rptunitOption" :key="index" :value="item.data" :label="item.display"></el-option>
                      </el-select>
                  </td>
              </tr>
          </table>
          <div style="text-align:right">
              <span class="dialog-footer" slot="footer">
                  <el-checkbox label="同时复制输入字段以外的设置" false-label="0" true-label="1" v-model="pagesettingcopyflag" style="margin-right:100px;"></el-checkbox>
                  <el-button @click="copyItem()">确 定</el-button>
                  <el-button @click="CopyShow=false">取 消</el-button>
              </span>
          </div>
      </el-dialog>
      <el-dialog width="900px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="报告单元" :visible.sync="dialogMultipleVisible" :destroy-on-close="true">
          <rm-SqlMultiple :leftOption="option1" :rightOption="option2" :name="fieldname" @change="closedialog"></rm-SqlMultiple>
      </el-dialog>
  </el-dialog>

</template>

<script>
import XE from "xe-utils";
export default {
  name: "rmlabreportconfig",
  props: ["rptunitid", "tableDataColumn", "ConfigDetail"],
  data() {
      return {
          //列配置弹出框
          ConfigVisible: false, //列配置显示标志
          rowdistance: 1, //行间距
          labelsize: "0", //字体大小
          selectConfig: { tigger: "row" }, //vxe表格选中方式
          keyConfig: {
              isDel: true,
              isTab: true,
              isEdit: true
          }, //vxe表格键盘事件
          currentindex: 0,
          dialogTableVisible: false,
          popdatatype: "LIS3_charge_typeno",
          InputCodeArr: [],
          //批量修改字段弹窗
          dialogBatVisible: false,
          inputcolcode: "",
          labgroupid: "",
          tableDataBatCol: [],
          tableDataBatCol1: [],
          BatOptions: [],
          CopyShow: false,
          rptunitidcopy: 0,
          option1: [],
          option2: [],
          fieldname: "rptunitid",
          dialogMultipleVisible: false,
          rptunitOption: [],
          pagesettingcopyflag: "1",
      };
  },
  created() {},
  methods: {
      currentChangeEvent({ row }) {
          this.currentindex = this.$refs.xTableColumn.getRowIndex(row);
      },
      SetFirst(table) {
          if (table.getCurrentRow()) {
              var currentrow = table.getCurrentRow();
              table.tableData = table.tableData.filter(item => item._XID != currentrow._XID);
              table.tableData.splice(0, 0, currentrow);
              this.currentindex = 0;
              this.$nextTick(() => {
                  table.setCurrentRow(currentrow);
                  table.scrollToRow(currentrow);
              });
          }
      },
      SetUp(table) {
          if (this.currentindex > 0) {
              var currentrow = table.getCurrentRow();
              table.tableData = table.tableData.filter(item => item._XID != currentrow._XID);
              table.tableData.splice(this.currentindex - 1, 0, currentrow);
              this.currentindex -= 1;
              this.$nextTick(() => {
                  table.setCurrentRow(currentrow);
                  table.scrollToRow(currentrow);
              });
          }
      },
      SetDown(table) {
          if (this.currentindex >= 0 && this.currentindex < table.tableData.length - 1) {
              var currentrow = table.getCurrentRow();
              table.tableData = table.tableData.filter(item => item._XID != currentrow._XID);
              table.tableData.splice(this.currentindex + 1, 0, currentrow);
              this.currentindex += 1;
              this.$nextTick(() => {
                  table.setCurrentRow(currentrow);
                  table.scrollToRow(currentrow);
              });
          }
      },
      SetLast(table) {
          if (table.getCurrentRow()) {
              var currentrow = table.getCurrentRow();
              table.tableData = table.tableData.filter(item => item._XID != currentrow._XID);
              table.tableData.push(currentrow);
              this.currentindex = table.tableData.length - 1;
              this.$nextTick(() => {
                  table.setCurrentRow(currentrow);
                  table.scrollToRow(currentrow);
              });
          }
      },
      resort(table) {
          var reg = new RegExp("[0-9]{1,}", "gi");
          var row = table.getCurrentRow();
          table.tableData.sort((a, b) => a._XID.match(reg) - 0 - (b._XID.match(reg) - 0));
          this.$nextTick(() => {
              table.setCurrentRow(row);
              this.currentindex = table.getRowIndex(row);
          });
      },
      BatChangeColumn() {
          this.inputcolcode = "";
          this.labgroupid = "";
          this.QueryBatCol();
          this.dialogBatVisible = true;
      },
      CopyToOtherUnit() {
          this.CopyShow = true;
          this.rptunitidcopy = "";
          this.$tool
              .request({
                  url: "ucent/ddl",
                  method: "post",
                  data: {
                      action: "getOption",
                  }
              })
              .then(res => {
                  this.rptunitOption = res.rptunitOption;
              })
              .catch((e) => {
                  console.log("error", e);
              });
      },
      copyItem() {
          var coldata = XE.clone(this.$refs.xTableColumn.tableData, true);
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS310",
                  method: "post",
                  data: {
                      action: "copypagesetting",
                      cols: coldata,
                      pageseting: this.ConfigDetail,
                      torptunitid: this.rptunitidcopy,
                      copypagesetting: this.pagesettingcopyflag,
                  },
              })
              .then((res) => {
                  if (res.flag == 1) {
                      this.$message({
                          message: "复制成功！",
                          type: "success",
                      });
                      this.CopyShow = false;
                  } else {
                      this.$alert("复制失败！" + res.msg, "提示");
                  }
              });
      },
      closedialog(value, name) {
          if (value != "close") {
              this.rptunitidcopy = value;
          }
          this.dialogMultipleVisible = false;
      },
      popMultipleChk(e) {
          let temp = XE.clone(this.rptunitOption, true);
          this.option1 = [];
          this.option2 = [];
          if (e != "") {
              let k = e.split(",");
              for (let i = 0; i < k.length; i++) {
                  let ndata = temp.find((m) => m.data.trim() == k[i]);
                  if (ndata != undefined && ndata != null) {
                      this.option2.push(ndata);
                  }
              }
              temp.forEach((item) => {
                  if (k.indexOf(item.data + "") < 0) {
                      this.option1.push(item);
                  }
              });
          } else {
              this.option1 = temp;
          }
          this.dialogMultipleVisible = true;
      },
      SaveCol() {
          var coldata = XE.clone(this.$refs.xTableColumn.tableData, true);
          // var pageseting = "";
          // for (let i = 0; i < this.ConfigDetail.tab_length - 1; i++) {
          //     if (this.ConfigDetail[i]) pageseting += "1,";
          //     else pageseting += "0,";
          // }
          // pageseting += this.ConfigDetail[this.ConfigDetail.tab_length - 1];
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS310",
                  method: "post",
                  data: {
                      action: "saveinputcol",
                      cols: coldata,
                      rptunitid: this.rptunitid,
                      pageseting: this.ConfigDetail
                  }
              })
              .then(res => {
                  if (res.Item1 == 1) {
                      this.$message({
                          type: "success",
                          message: "保存成功!"
                      });
                      this.ConfigVisible = false;
                      // this.$parent.GetOptions(this.rptunitid).then(r => {
                      //     this.$parent.QueryCol();
                      // });
                  } else {
                      this.$message.error("错误:" + res.Item2);
                  }
              })
              .catch(error => {
                  this.$message.error("错误:" + error);
              });
      },
      OpenConfig() {
          this.ConfigVisible = true;

          this.$nextTick(() => {
              this.$refs.xTableColumn.loadData(this.tableDataColumn).then(() => {
                  this.$refs.xTableColumn.setCurrentRow(this.$refs.xTableColumn.getData(0));
                  this.currentindex = 0;
              });
          });
      },

      //input输入框双击事件
      inputdblEvent(colcode) {
          this.popdatatype = "LIS3_" + colcode;
          let selitem = this.tableDataColumn.find(item => item.col_code == colcode);
          if (selitem) this.poptitle = selitem.col_name;
          else this.poptitle = "";
          this.dialogTableVisible = true;
      },
      inputChangeEvent(val, colcode) {
          if (val == "") {
              var selitem = this.$refs.xTableColumn.tableFullData.find(item => item.col_code == colcode);
              console.log("index1", selitem);
              if (selitem) {
                  var index = this.$refs.xTableColumn.tableFullData.indexOf(selitem);
                  console.log("index", index);
                  this.$refs.xTableColumn.tableFullData[index].default_val = "";
                  this.$refs.xTableColumn.tableFullData[index].default_valname = "";
              }
              this.$emit("configDefChange", { row: "", colcode: colcode });
          }
      },

      inputBatChangeEvent(value, row) {
          if (value != "") {
              var selitem = this.BatOptions.find(item => item.hidkey == value || item.hidname == value);
              if (selitem) {
                  row.default_valname = selitem.hidname;
                  row.default_val = selitem.hidkey;
              } else {
                  row.default_valname = value;
                  row.default_val = value;
              }
          } else {
              row.default_valname = "";
              row.default_val = "";
          }
      },
      popchange(c, v, row) {
          var data = this.tableDataColumn;
          var colcode = this.popdatatype.replace("LIS3_", "");
          let selitem = data.find(item => item.col_code == colcode);
          if (selitem) {
              this.$emit("configDefChange", { row: row, colcode: colcode });
              // this.$parent.tableDataColumn[index].default_val = c;
              // this.$parent.tableDataColumn[index].default_valname = v;
              // this.$forceUpdate();
          }
          this.dialogTableVisible = false;
      },

      popinputchange(value, type) {
          let selitem = this.tableDataColumn.find(item => item.col_code == type);
      },

      Queryddl(colcode) {
          if (!this.InputCodeArr.find(item => item.key == colcode)) {
              this.$tool
                  .request({
                      url: "ucent/ddl",
                      method: "post",
                      data: {
                          action: colcode,
                          rptunitid: this.rptunitid
                      }
                  })
                  .then(res => {
                      if (!res.hasOwnProperty("errcode")) {
                          this.InputCodeArr.push({ key: colcode, list: res });
                      }
                  });
          }
      },
      headerdblCellClickEvent({ column }) {
          if (this.$refs.xTableBatColumn.tableFullData.length > 0) {
              var rowdata = this.$refs.xTableBatColumn.tableFullData[0];
              for (let i = 0; i < this.$refs.xTableBatColumn.tableFullData.length; i++) {
                  this.$refs.xTableBatColumn.tableFullData[i][column.property] = rowdata[column.property];
              }
          }
      },
      QueryBatCol() {
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS310",
                  method: "post",
                  data: {
                      action: "querybatinputcol",
                      colcode: this.inputcolcode,
                      labgroupid: this.labgroupid
                  }
              })
              .then(res => {
                  if (res) {
                      this.tableDataBatCol = res.dt;
                      this.tableDataBatCol1 = res.noExitRptunit;
                      this.$refs.xTableBatColumn.loadData(this.tableDataBatCol);
                      this.BatOptions = res.options;
                  } else {
                      this.$message.error("错误:" + res.errmsg);
                  }
              })
              .catch(error => {
                  this.$message.error("错误:" + error);
              });
      },
      //补全所有报告单元
      btngetAllRptunit() {
          if (this.tableDataBatCol1.length > 0) {
              this.tableDataBatCol1.forEach((item) => {
                  this.$refs.xTableBatColumn.insert(item);
              });
          }

      },
      //保存批量修改字段
      SaveBatCol() {
          var urec = this.$refs.xTableBatColumn.getRecordset();
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS310",
                  method: "post",
                  data: {
                      action: "savebatinputcol",
                      urec: urec
                  }
              })
              .then(res => {
                  if (res.errcode == "1") {
                      this.$message.success("保存成功!");
                      this.QueryBatCol();
                  } else {
                      this.$message.error("错误:" + res.errmsg);
                  }
              })
              .catch(error => {
                  this.$message.error("错误:" + error);
              });
      }
  },
  watch: {
      ConfigVisible(val) {
          if (!val) {
              this.$emit("close");
          }
      }
  }
};
</script>
<style scoped>
/* table tr td:nth-child(odd) {
  text-align: right;
  white-space: nowrap;
}
table tr td:nth-child(even) {
  text-align: left;
}
table tr td:nth-child(1) {
  width: 80px;
} */
table {
  font-size: 12px;
  border-collapse: separate;
  /* border-spacing: 5px; */
}
/deep/.processingcls td {
  color: #1087ba;
}
/deep/.errocls td {
  color: red;
}
/deep/.erroalreadyread td {
  color: #0a5fb4;
}
.barcoderunning::-webkit-input-placeholder {
  color: #ff0000;
}
/deep/ .parent-row .vxe-cell {
  width: 100% !important;
}
.parent-row-name {
  display: inline-block;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
}
.top-sample-info {
  font-weight: bold;
  font-size: 13px;
  margin-right: 30px;
}

.top-row {
  display: block;
  width: 100%;
  font-size: 12px;
  margin-top: 5px;
}
.top-row span {
  display: inline-block;
}
.top-row-title {
  margin: 0 5px;
}
.title-content {
  width: 48px;
  text-align: right;
}
.top-row-content {
  display: flex;
  justify-content: space-between;
}
</style>
